var remainSecondTipTimer;
var lockFlag = false;
var getSmscodeMin = 2;
$(document).ready(function() {
			//注册
			$("#btn_submit").click(function() {
						if (!verifyInputFieldShow("msisdn,name,password1,password2"))
							return;
						if(!checkPhoneAndShow($("#msisdn").val(),"msisdn")){
							return;
						}
						if ($("#password1").val() != $("#password2").val())
						{
							$("#password2_msg").css("color","red");
							$("#password2_msg").empty().html("两次输入的密码不一致");
							return;
						}
						if (!verifyCheckboxFieldShow("agree_protocol","同意《华农网上餐厅服务协议》","chk_agree"))
							return;
						//将密码MD5加密后赋值给隐藏域提交给后台
						$("#hid_password").val(hex_md5($("#password1").val()));
						$("#frm_submit").submit();

					});
		});
		
		
		
document.onkeydown = function(e) {
	e = e || window.event;
	var ch = e.which || e.keyCode;
	if (ch == 13) {
		$("#btn_submit").trigger("click");
	}
}
function refresh() {
	$("#img_code")[0].src = "kaptcha.jpg?t=" + Math.random();
}
function remainSencodTip() {
	if (remainCount == 0) {
		$("#picCaptcha").val("");
		refresh();
		$("#btn_sendSmCode").val("重新获取验证码").attr("disabled", false);
		lockFlag = false;
		clearInterval(remainSecondTipTimer);
		return;
	}
	$("#btn_sendSmCode").val(remainCount + "秒后可重新获取");
	remainCount--;
}
function pop_protocol(id) {
	$('.pop_protocol').empty().html($("#" + id).html());
	showPop('pop_protocol');
}
function agreeTreaty() {
	popclose();
	$(":checkbox[name='agree_protocol']").attr("checked", true);
}
function checkPhone(){
	var phone = trimAllSpace($("#msisdn").val());
	return checkPhoneAndShow(phone,"msisdn");
}
function checkPic(){
	$.get("captcha/check/pic/" + $("#picCaptcha").val(), {}, function(data) {
												if (!data.result) {
													// alertWarnMsg(data.message);
													showMsgAndFocus(data.message,"#picCaptcha",false);
													return;
												}});
	
}